﻿@inherits BaseComponent

<KLayout>
    <div class="kui-app">
        @if (!IsHome)
        {
            <div class="kui-app-nav">
                @if (!string.IsNullOrWhiteSpace(App?.CurrentMenu?.BackUrl))
                {
                    <span class="back" @onclick="e=>App?.Back()">
                        <Icon Type="left" Theme="IconThemeType.Outline" />
                        <span>返回</span>
                    </span>
                }
                @App?.CurrentMenu?.Name
            </div>
        }
        <div class="@pageClass">
            @ChildContent
        </div>
        @if (IsTab)
        {
            <AppTab Items="Config.AppMenus" />
        }
    </div>
</KLayout>

@code {
    private bool IsHome => Context.Url == "/app";
    private bool IsTab => Context.Current?.Target == "Tab";
    private string pageClass => CssBuilder.Default("kui-app-page")
                                          .AddClass("nav", !IsHome)
                                          .AddClass("tab", IsTab)
                                          .BuildClass();

    [Parameter] public RenderFragment ChildContent { get; set; }
}